<style>
    legend {
        width: auto !important;
        border-style: none !important;
    }

    body {
        font-size: initial;
    }

    .xzw_starSys .current-rating {
        position: inherit;
    }

    .xzw_starSys {
        padding: inherit;
        margin: auto;
    }
</style>
<div class="layui-card-body">
    <!--基本信息-->
    <div class="layui-form" lay-filter="layuiadmin-form-order" id="layuiadmin-form-order">
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>订单信息</legend>
            </fieldset>
        </div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">订单编号：<?= $data['order_sn'] ?></div>
                <div class="col-xs-4">下单时间：<?= $data['create_time'] ?></div>
            </div>
        </div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">支付状态：<?= $pay_status[$data['pay_status']] ?? '' ?></div>
                <div class="col-xs-4">支付时间：<?= $data['pay_time'] ?></div>
                <div class="col-xs-4">订单状态：<?= $order_status[$data['order_status']] ?? '' ?></div>
            </div>
        </div>

        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>会员信息</legend>
            </fieldset>
        </div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">会员编号：<?= $res[$data['userid']]['id'] ?? '' ?></div>
                <div class="col-xs-4">会员昵称：<?= $res[$data['userid']]['nickname'] ?? '' ?></div>
                <div class="col-xs-4">手机号码：<?= $res[$data['userid']]['mobile'] ?? '' ?></div>
            </div>
        </div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">注册时间：<?= $res[$data['userid']]['create_time'] ?? '' ?></div>
            </div>
        </div>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>佣金信息</legend>
            </fieldset>
        </div>
        <div>佣金计算方式：批发价*抽成</div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">校区佣金：<?= $data['ca_brokerage'] ?></div>
                <div class="col-xs-4">校区价：<?= $data['ca_price'] ?></div>
            </div>
        </div>
        <hr>
        <div>佣金计算方式：（商品金额-批发价）*每级的分销比例</div>
        <?php if ($data['second_level']): ?>
            <div class="layui-form-item div-flex">
                <div class="row row-no-gutters">
                    <div class="col-xs-4">上级编号：<?= $data['second_level'] ?></div>
                    <div class="col-xs-4">上级昵称：<?= $res[$data['second_level']]['nickname'] ?? '' ?></div>
                    <div class="col-xs-4">上级佣金：<?= $data['second_brokerage'] ?></div>
                </div>
            </div>
        <?php endif; ?>
        <?php if ($data['one_level']): ?>
            <div class="layui-form-item div-flex">
                <div class="row row-no-gutters">
                    <div class="col-xs-4">上上级编号：<?= $data['one_level'] ?></div>
                    <div class="col-xs-4">上上级昵称：<?= $res[$data['one_level']]['nickname'] ?? '' ?></div>
                    <div class="col-xs-4">上上级佣金：<?= $data['one_brokerage'] ?></div>
                </div>
            </div>
        <?php endif; ?>
        <?php if ($data['top_level']): ?>
            <div class="layui-form-item div-flex">
                <div class="row row-no-gutters">
                    <div class="col-xs-4">上上上级编号：<?= $data['top_level'] ?></div>
                    <div class="col-xs-4">上上上级昵称：<?= $res[$data['top_level']]['nickname'] ?? '' ?></div>
                    <div class="col-xs-4">上上上级佣金：<?= $data['top_brokerage'] ?></div>
                </div>
            </div>
        <?php endif; ?>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>收货信息</legend>
            </fieldset>
        </div>
        <div class="layui-form-item div-flex">
            <div class="row row-no-gutters">
                <div class="col-xs-4">提货方式：<?= $delivery_method[$data['delivery_method']] ?? '' ?></div>
                <?php if ($data['delivery_method'] == 2): ?>
                    <div class="col-xs-4">校区：<?= $receipt_info['campus_name'] ?></div>
                    <div class="col-xs-4">联系人：<?= $receipt_info['consignee'] ?></div>
                    <div class="col-xs-4">联系方式：<?= $receipt_info['mobile'] ?></div>
                    <div class="col-xs-4">楼号/门牌号：<?= $receipt_info['address'] ?></div>
                <?php endif; ?>
            </div>
        </div>
        <?php if ($data['delivery_method'] == 2): ?>
            <div class="layui-form-item">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>接单信息</legend>
                </fieldset>
            </div>
            <div class="row row-no-gutters">
                <div class="col-xs-4">接单限制：<?= $astrict_sex[$data['snatch_sex']] ?? '' ?></div>
            </div>
            <div class="layui-form-item table-margin">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>跑腿信息</th>
                        <th>状态</th>
                        <th>接单时间</th>
                        <th>取货时间</th>
                        <th>送达时间</th>
                        <th>取消时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($receiv as $it): ?>
                        <tr>
                            <td>
                                <?php $run_info = json_decode($it['run_info'], true);
                                echo $run_info['name'] ?? ''; ?>
                            </td>
                            <td><?= $receiv_status[$it['status']] ?? '' ?></td>
                            <td><?= $it['create_time'] ?></td>
                            <td><?= $it['pickup_time'] ?></td>
                            <td><?= $it['deliver_time'] ?></td>
                            <td><?= $it['cancel_time'] ?></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php endif; ?>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>收货信息</legend>
            </fieldset>
        </div>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>商品信息</legend>
            </fieldset>
        </div>

        <div class="layui-form-item table-margin">
            <table class="layui-table">

                <thead>
                <tr>
                    <th>商品信息</th>
                    <th>价格(元)</th>
                    <th>数量</th>
                    <th>批发价</th>
                    <th>校区价</th>
                    <th>小计(元)</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($spec as $good): ?>
                    <tr>
                        <td>
                            <div style="text-align: left">
                                <div class="layui-col-md5">
                                    <img src="<?= $good['main_img'] ?>" class="image-show image">
                                </div>
                                <div class="layui-col-md5">
                                    <p style="margin-top: 10px"><?= $good['good_name'] ?></p>
                                    <br>
                                    <p><?= $good['spec_name'] ?></p>
                                </div>
                            </div>
                        </td>
                        <td>￥<?= $good['good_price'] ?></td>
                        <td><?= $good['good_num'] ?></td>
                        <td><?= $good['trade_price'] ?></td>
                        <td><?= $good['ca_price'] ?></td>
                        <td><?= $good['total_price'] ?></td>
                    </tr>
                <?php endforeach; ?>
                <tr>
                    <td colspan="5"></td>
                    <td style="text-align: left">
                        <p>商品金额:￥<?= $data['total_amount'] ?></p>
                        <p>批发价:￥<?= $data['trade_price'] ?></p>
                        <p>优惠金额:￥<?= $data['discount_amount'] ?></p>
                        <p style="color: red">配送费:￥<?= $data['delivery_fee'] ?></p>
                        <p style="color: red">支付金额:￥<?= $data['pay_amount'] ?></p>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>买家留言</legend>
            </fieldset>
        </div>

        <div class="layui-form-item table-margin">
            <textarea class="layui-textarea" disabled=""><?= $data['user_remarks'] ?></textarea>
        </div>


        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>订单操作</legend>
            </fieldset>
        </div>

        <div class="layui-form-item div-flex ">
            <div class="layui-input-block ">
                <?php if ($data['order_status'] == 1): ?>
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                            onclick="deliver('<?= $data['id'] ?>')">发货
                    </button>
                <?php endif; ?>
            </div>
        </div>
        <div class="layui-form-item">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>订单日志</legend>
            </fieldset>
        </div>

        <div class="layui-form-item table-margin">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>操作类型</th>
                    <th>时间</th>
                    <th>动作类型</th>
                    <th>日志内容</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($log as $it): ?>
                    <tr>
                        <td><?= $order_log_type[$it['type']] ?? '' ?></td>
                        <td><?= $it['create_time'] ?></td>
                        <td><?= $it['action'] ?></td>
                        <td><?= $it['content'] ?></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>


    </div>
</div>
<script>
    <?php $this->beginBlock('js_end')?>
    function deliver(id) {
        $.modal.open("发货", '<?=\yii\helpers\Url::to(['deliver'])?>?id=' + id, '80', '80', null, '%');
    }
    <?php $this->endBlock()?>
</script>
<?php $this->registerJs($this->blocks['js_end'], \yii\web\View::POS_END); ?>